package com.decent.ejfadmin.report.controller;

import com.decent.ejfadmin.common.bean.ExkDailyReportBean;
import com.decent.ejfadmin.common.bean.MessageBean;
import com.decent.ejfadmin.common.enums.ExkChannelPlat;
import com.decent.ejfadmin.report.service.CollectCardProfitDailyReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

/**
 * @author weicx
 * @date 2018/08/01
 */
@RestController
@Slf4j
@RequestMapping("CollectCardProfitDailyReportController")
public class CollectCardProfitDailyReportController {
    @Autowired
    private CollectCardProfitDailyReportService collectCardProfitDailyReportService;

    /**
     * 查询销卡利润
     *
     * @param startTime      查询开始时间
     * @param endTime        查询结束时间
     * @param exkChannelPlat 销卡渠道
     * @return
     */
    @RequestMapping("/queryDailyReport")
    public List<ExkDailyReportBean> queryDailyReport(String startTime, String endTime, ExkChannelPlat exkChannelPlat) {
        try {
            return collectCardProfitDailyReportService.queryDailyReport(startTime, endTime, exkChannelPlat);
        } catch (Exception e) {
            log.warn("销卡利润统计异常:[{}]", e);
            return Collections.emptyList();
        }

    }


    /**
     * 利润统计
     *
     * @param startTime 统计时间
     * @return
     */
    @RequestMapping("/profitDailyReport")
    public MessageBean profitDailyReport(String startTime) {
        try {
            return collectCardProfitDailyReportService.profitDailyReport(startTime);
        } catch (Exception e) {
            log.warn("销卡利润统计异常:[{}]", e);
            return MessageBean.fail();
        }

    }
}
